package Controllayer;
import DBlayer.*;
import java.util.ArrayList;
import Modellayer.*;

/**
 *
 * @author Søren
 */
public class OrderCtr
{


       public OrderCtr()
    {

    }


        public ArrayList findAllSales()
        {
            IFDBSalesOrder dbSalesOrder = new DBSalesOrder();
            ArrayList allSalesOrder = new ArrayList();
            allSalesOrder = dbSalesOrder.getAllOrders(false);
            return allSalesOrder;
        }

        public SalesOrder findSalesOrder(int salesOrderID, boolean retriveAssociation)
	{
		IFDBSalesOrder dbSalesOrder = new DBSalesOrder();
                return dbSalesOrder.findOrder(salesOrderID, true);
	}

	public int updateOrder(int salesOrderID, Customer customer, SalesLineItem salesLine, String dato, int amount, String deliveryStatus, String deliveryDate)
      {
          IFDBSalesOrder dbSalesOrder = new DBSalesOrder();
          SalesOrder sale = new SalesOrder();
          sale.setSalesOrderID(salesOrderID);
          sale.setSalesOrderID(salesOrderID);
          sale.setCustomer(customer);
          sale.setSalesLine(salesLine);
          sale.setDato(dato);
          sale.setDeliveryStatus(deliveryStatus);
          sale.setDeliveryDate(deliveryDate);
          return  dbSalesOrder.updateSalesOrder(sale);
      }

        public void insertSalesOrder(SalesOrder saleObj)
      {
           IFDBSalesOrder dbSalesOrder = new DBSalesOrder();
           dbSalesOrder.insertSalesOrder(saleObj);
      }


        public void deleteSalesOrder(int ID)
	{
            IFDBSalesOrder dbSalesOrder = new DBSalesOrder();
            dbSalesOrder.deleteOrder(ID);
	}

        public ArrayList findSalesLine(int salesOrderID)
        {
          IFDBSalesLineItem dbSalesLine = new DBSalesLineItem();
          ArrayList<SalesLineItem> result = dbSalesLine.findSalesLine(salesOrderID);
          return result;
         }
		
		public void insertSalesLine(SalesLineItem tempLine)
	{
		IFDBSalesLineItem dbSalesLineItem = new DBSalesLineItem();
		dbSalesLineItem.insertSalesLine(tempLine);
	}
}
